package epam.bookShelf.actions;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import epam.bookShelf.actors.Reader;

/**
 * Logout session (delete AUTH attribute from user session) 
 * @author Pustovit Michael, pustovitm@gmail.com
 */
public class LogoutAction extends Action {

	@Override
	public void run(HttpServletRequest request, 
			HttpServletResponse response,
			ServletContext context) throws ServletException, IOException 
	{		
		HttpSession session = request.getSession(false);
		if (session != null) {
			session.removeAttribute(Reader.AUTH_SESSION_ATTRIBUTE);			
		}
	}

}
